﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Util.Domains;

namespace IterationLife.UserProfiles.Models {
    /// <summary>
    /// 用户身体信息
    /// </summary>
    [Description( "用户身体信息" )]
    public partial class UserBodyInfo : AggregateRoot<UserBodyInfo> {
        /// <summary>
        /// 初始化用户身体信息
        /// </summary>
        public UserBodyInfo() : this( Guid.Empty ) {
        }

        /// <summary>
        /// 初始化用户身体信息
        /// </summary>
        /// <param name="id">用户身体信息标识</param>
        public UserBodyInfo( Guid id ) : base( id ) {
        }

        /// <summary>
        /// 用户资料编号
        /// </summary>
        [Required(ErrorMessage = "用户资料编号不能为空")]
        public Guid UserProfileId { get; set; }
        /// <summary>
        /// 身高
        /// </summary>
        public decimal? Height { get; set; }
        /// <summary>
        /// 体重
        /// </summary>
        public decimal? Weight { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }
        
        /// <summary>
        /// 用户资料
        /// </summary>
        public virtual UserProfile UserProfile { get; set; }
        
        /// <summary>
        /// 添加描述
        /// </summary>
        protected override void AddDescriptions() {
            AddDescription( "用户身体信息编号", Id );
            AddDescription( "用户资料编号", UserProfileId );
            AddDescription( "身高", Height );
            AddDescription( "体重", Weight );
            AddDescription( "创建时间", CreationTime );
        }
        
        /// <summary>
        /// 添加变更列表
        /// </summary>
        protected override void AddChanges( UserBodyInfo newEntity ) {
            AddChange( "Id", "用户身体信息编号", Id, newEntity.Id );            
            AddChange( "UserProfileId", "用户资料编号", UserProfileId, newEntity.UserProfileId );
            AddChange( "Height", "身高", Height, newEntity.Height );
            AddChange( "Weight", "体重", Weight, newEntity.Weight );
            AddChange( "CreationTime", "创建时间", CreationTime, newEntity.CreationTime );
        }
    }
}